<template>
    <div style="width: 100%;">
        <el-page-header @back="goBack" content="分包招标采购计划明细查询">
        </el-page-header>
        <el-divider></el-divider>
        <el-form :inline="true">
            <el-form-item>
                <el-input v-model="params.planId" placeholder="招标编号" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="params.projectName" placeholder="项目名称" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="params.subProject" placeholder="分包项目" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="params.subProviders" placeholder="候选供应商" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item style="margin-left: 10px">
                <el-button @click="handleSearch" type="primary">检索</el-button>
            </el-form-item>
        </el-form>

        <el-table :data="pageResult.records">
            <el-table-column label="序号" type="index"></el-table-column>
            <el-table-column label="招标编号" prop="subtenderId"></el-table-column>
            <el-table-column label="项目名称" prop="projectName"></el-table-column>
            <el-table-column label="编制人" prop="planEditor"></el-table-column>
            <el-table-column label="日期" prop="date"></el-table-column>
            <el-table-column label="分包项目" prop="subProject"></el-table-column>
            <el-table-column label="分包工作内容" prop="subContent"></el-table-column>
            <el-table-column label="计划招标时间" prop="tenderDate"></el-table-column>
            <el-table-column label="组织招标方" prop="tenderer"></el-table-column>
            <el-table-column label="分包方式" prop="subTenderType">
                <template slot-scope="scope">
                    {{getSubTenderType(scope.row.subTenderType)}}
                </template>
            </el-table-column>
            <el-table-column label="分包商选择方式" prop="subProviderChoose">
                <template slot-scope="scope">
                    {{getSubProviderChoose(scope.row.subProviderChoose)}}
                </template>
            </el-table-column>
            <el-table-column label="候选分包商" prop="subProviders"></el-table-column>
        </el-table>
        <el-divider></el-divider>

        <el-footer class="case-list-footer">
            <el-pagination
                    style="margin: 10px auto"
                    background
                    layout="total , sizes ,prev, pager, next,jumper"
                    :page-sizes="[5,10,15,20]"
                    :total="pageResult.total"
                    :page-size="pageResult.size"
                    class="pagination"
                    @current-change="handleIndexChange"
                    @size-change="handleSizeChange"
            >
            </el-pagination>
        </el-footer>
    </div>
</template>

<script>
    import {SubTenderDetailService} from "../../../model/gs/SubTenderDetailService";

    const subTenderDetailService = SubTenderDetailService.getInstance()

    export default {
        data() {
            return {
                params: {
                    planId: '',
                    projectName: '',
                    subProject: '',
                    subProviders: ''
                },
                pageResult:[]
            }
        },
        methods:{
            getSubTenderDetailList(){
                subTenderDetailService.getPageList(this.params).then(response => {
                    if(response.data.code === 0){
                        this.pageResult = response.data.data
                    }
                })
            },
            handleSearch(){
                this.params.page = 1
                this.getSubTenderDetailList()
            },
            handleIndexChange(index){
                this.params.page = index
                this.getSubTenderDetailList()
            },
            handleSizeChange(size){
                this.params.size = size
                this.getSubTenderDetailList()
            },
            getSubTenderType(subTenderType){
                switch (subTenderType) {
                    case '1' : return '包工包料'
                    case '2' : return '劳务'
                    case '3' : return '包工及部分材料'
                    case '4' : return '其他'
                }
            },
            getSubProviderChoose(subProviderChoose){
                switch (subProviderChoose) {
                    case '1' : return '公司选定'
                    case '2' : return '业主选定'
                    case '3' : return '项目选定'
                    case '4' : return '项目选择公司批准'
                    case '5' : return '业主指定我方签合同'
                    case '6' : return '业主项目共同选择'
                    case '7' : return '其他'
                }
            },
            goBack(){
                history.back()
            }
        },
        created(){
            this.getSubTenderDetailList()
        }
    }
</script>

<style scoped>

</style>
